package com.hmall.api.client;

import com.hmall.api.domain.dto.CartFormDTO;
import com.hmall.api.domain.po.Cart;
import com.hmall.api.domain.vo.CartVO;
import feign.Param;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 购物车相关接口
 */
@FeignClient("cart-service")
public interface CartClient {

    @ApiOperation("添加商品到购物车")
    @PostMapping("/carts")
    void addItem2Cart(@Valid @RequestBody CartFormDTO cartFormDTO);

    @ApiOperation("更新购物车数据")
    @PutMapping("/carts")
    void updateCart(@RequestBody Cart cart);

    //删除购物车中商品
    @DeleteMapping("/carts/{id}")
    void deleteCartItem(@Param("购物车条目id")@PathVariable("id") Long id);

    //查询购物车列表
    @GetMapping("/carts")
    List<CartVO> queryMyCarts();

    //批量删除购物车中商品 trade-service调用，验证通过。需要在cart表中加数据
    //@ApiImplicitParam(name = "ids", value = "购物车条目id集合")
    @DeleteMapping("/carts")
    void deleteCartItemByIds(@RequestParam("ids") List<Long> ids);
}